load("@rules_proto//proto:defs.bzl", "proto_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")

proto_library(
    name = "raftpb_proto",
    srcs = ["raft.proto"],
    strip_import_prefix = "/pkg",
    visibility = ["//visibility:public"],
    deps = ["@com_github_gogo_protobuf//gogoproto:gogo_proto"],
)

go_proto_library(
    name = "raftpb_go_proto",
    compilers = ["//pkg/cmd/protoc-gen-gogoroach:protoc-gen-gogoroach_compiler"],
    importpath = "github.com/cockroachdb/cockroach/pkg/raft/raftpb",
    proto = ":raftpb_proto",
    visibility = ["//visibility:public"],
    deps = [
        "@com_github_gogo_protobuf//gogoproto",
    ],
)

go_library(
    name = "raftpb",
    srcs = [
        "confchange.go",
        "confstate.go",
        "raft.go",
    ],
    embed = [":raftpb_go_proto"],
    importpath = "github.com/cockroachdb/cockroach/pkg/raft/raftpb",
    visibility = ["//visibility:public"],
    deps = [
        "@com_github_cockroachdb_redact//:redact",
        "@com_github_gogo_protobuf//proto",
    ],
)

go_test(
    name = "raftpb_test",
    srcs = [
        "confstate_test.go",
        "raft_test.go",
    ],
    embed = [":raftpb"],
)
